﻿using MB.Orm.DB;
using MB.RuleBase.Common;
using Model;
using Public.DataAccess;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Business
{
    public class BWarrantyTime
    {
        public BWarrantyTime() { }

        /// <summary>
        /// 获取日志信息
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="total"></param>
        /// <param name="parValues"></param>
        /// <returns></returns>
        public List<WarrantyTime> GetWarrantyTimeInfo(int pageIndex, int pageSize, out int total, params object[] parValues)
        {
            using (var DbScope = new OperationDatabaseScope(new OperationDatabaseContext("NewWeb")))
            {
                List<WarrantyTime> list = PagedDatabaseExcuteByXmlHelper.NewInstance.GetPagedObjectsByXml3<WarrantyTime>
                                                ("WarrantyTime", "GetWarrantyTimeInfo", pageIndex, pageSize, out total, parValues);
                return list;
            }
        }

        /// <summary>
        /// 根据开始时间查询这个时间段是否存在
        /// </summary>
        /// <param name="seedType"></param>
        /// <returns></returns>
        public List<WarrantyTime> GetWarrantyTimeInfoByDay(int beginInt,int endInt)
        {
            using (var DbScope = new OperationDatabaseScope(new OperationDatabaseContext("NewWeb")))
            {
                List<WarrantyTime> lmWarrantyTimelist = DatabaseExcuteByXmlHelper.NewInstance.GetObjectsByXml<WarrantyTime>("WarrantyTime", "GetWarrantyTimeInfoByDay", beginInt, endInt);
                return lmWarrantyTimelist;
            }
        }


        /// <summary>
        /// 新增临保期期计算规则
        /// </summary>
        /// <param name="location"></param>
        /// <returns></returns>
        public int AddWarrantyTimeInfo(WarrantyTime lmWarrantyTime)
        {
            return DatabaseExcuteByXmlHelper.NewInstance.ExecuteNonQueryByEntity<WarrantyTime>("WarrantyTime", "AddWarrantyTimeInfo", lmWarrantyTime);
        }

    }
}
